home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
By Popular Request 2.0
/
By Popular Request 2.0 (Arsenal Computer).ISO
/
amiga_2
/
cd32gods.lha
/
cdaudio.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-04-22
|
3KB
|
131 lines
/*
written by Daniel Balster, dbalster@uni-paderborn.de
*/
#include <exec/exec.h>
#include <dos/dos.h>
#include <devices/cd.h>
#include <proto/exec.h>
#include <proto/dos.h>
#define TEMPLATE "PAUSE/S,PLAY/S,TRACK/N/K,LENGTH/N/K,FADE/N/K,VOLUME/N/K,MOTOR/N/K,SEARCH/N/K"
/*
PAUSE -> drive is in PAUSE mode (laser beam locks)
PLAY -> drive is in PLAY mode (laser beam unlocks)
TRACK -> track to play. default is first track
LENGTH -> how many tracks to play. default is 1000 tracks (only used in conjunction with TRACK)
FADE -> duration of volume fade. default is 0 (only used in conjunction with VOLUME)
VOLUME -> volume from 0..16383. default is maximum volume. <2048 == mute audio
MOTOR -> 0 to stop drive motor, 1 to restart drive motor.
SEARCH -> play mode: 0 is normal mode (default), 1 is fast forward and 2 is fast reverse mode
*/
struct {
ULONG pause,play,track,length,fade,volume,motor,search;
BOOL quiet;
ULONG pads[7];
} args = {0};
void pause (struct IOStdReq *ior, int pausemode)
{
ior->io_Command = CD_PAUSE;
ior->io_Data = NULL;
ior->io_Length = pausemode;
ior->io_Offset = 0;
DoIO(ior);
}
void motor (struct IOStdReq *ior, int state)
{
ior->io_Command = CD_MOTOR;
ior->io_Data = NULL;
ior->io_Length = state;
ior->io_Offset = 0;
DoIO(ior);
}
void playtrack (struct IOStdReq *ior, int numtracks, int firsttrack)
{
ior->io_Command = CD_PLAYTRACK;
ior->io_Data = NULL;
ior->io_Length = numtracks;
ior->io_Offset = firsttrack;
SendIO(ior);
}
void playmode (struct IOStdReq *ior, int playmode)
{
ior->io_Command = CD_SEARCH;
ior->io_Data = NULL;
ior->io_Length = playmode;
ior->io_Offset = 0;
DoIO(ior);
}
void attenuate (struct IOStdReq *ior, int duration, int volume)
{
ior->io_Command = CD_ATTENUATE;
ior->io_Data = NULL;
ior->io_Length = duration;
ior->io_Offset = volume;
DoIO(ior);
}
int main (void)
{
struct RDArgs *rdargs;
struct MsgPort *mp;
struct IOStdReq *ior;
int length=1, fade=0;
if (rdargs=ReadArgs(TEMPLATE,(LONG*)&(args),NULL))
{
if(!args.quiet) PutStr("*** CD Audio v1.0.0 *** by Daniel Balster\n");
if(mp=CreateMsgPort())
{
if(ior=(struct IOStdReq*)CreateIORequest(mp,sizeof(struct IOStdReq)))
{
if(!OpenDevice("cd.device",0,ior,0))
{
if (args.pause) pause(ior,1);
if (args.play) pause(ior,0);
if (args.length) length = *(ULONG*)args.length;
if (args.track) playtrack(ior,length,*(ULONG*)args.track);
if (args.fade) fade = *(ULONG*)args.fade;
if (args.volume) attenuate(ior,fade,*(ULONG*)args.volume);
if (args.motor) motor(ior,*(ULONG*)args.motor);
if (args.search) playmode(ior,*(ULONG*)args.search);
CloseDevice((struct IORequest*)ior);
}
else PutStr("cannot access cd.device?\n");
DeleteIORequest((struct IORequest*)ior);
}
else PutStr("cannot create ioreq?\n");
DeleteMsgPort(mp);
}
else PutStr("cannot create msgport?\n");
FreeArgs(rdargs);
}
else PrintFault(IoErr(),0);
return RETURN_OK;
}